<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>JavaScript Number 对象-精度-小数</title>
</head>

<body>
    <!-- 小数的最大位数是 17，但是浮点运算并不总是 100% 准确： -->
    <script>
        var x;
        document.write("<p>仅显示17位: ");
        x = 12345678901234567890;
        document.write(x + "</p>");
        document.write("<p>0.2 + 0.1 = ");
        x = 0.2 + 0.1;
        document.write(x + "</p>");
        document.write("<p>可以通过乘以10或除以10来计算: ");
        x = (0.2 * 10 + 0.1 * 10) / 10;
        document.write(x + "</p>");
    </script>
</body>

</html>